//
//  YHYReSubEveryDayCollectionViewCell.m
//  TripTogether
//
//  Created by 杨泓晔 on 15/12/30.
//  Copyright © 2015年 杨泓晔. All rights reserved.
//

#import "YHYReSubEveryDayCollectionViewCell.h"


@interface YHYReSubEveryDayCollectionViewCell ()
//@property (nonatomic,retain)UI
@property (nonatomic,retain) UIView *backView;/**<白板*/
@property (nonatomic,retain) UIImageView *myImageView;
@property (nonatomic,retain) UILabel *textLabel;/**<text内容*/
@property (nonatomic,retain) UILabel *nameLabel;/**<name*/
@property (nonatomic,retain) UIImageView *userImageView;

@end


@implementation YHYReSubEveryDayCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatCell];
    }
    return self;
}
- (void)creatCell{
    _backView = [UIView new];
    [self.contentView addSubview:_backView];
    _backView.backgroundColor = [UIColor whiteColor];
    
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(@0);
        
    }];
    _backView.layer.masksToBounds = YES;
    //    设置半径
    _backView.layer.cornerRadius = 5;
    
    
    
    self.myImageView = [UIImageView new];
    self.myImageView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.myImageView];
    
    [self.myImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(@0);
        make.height.mas_equalTo(140);
        
    }];
    // 设置照片左上角和左下角为圆角
    // 设置照片左上角和左下角为圆角
    //    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.imagePhoto.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(4, 4)];
    //    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    //    maskLayer.frame = self.imagePhoto.bounds;
    //    maskLayer.path = maskPath.CGPath;
    //    self.imagePhoto.layer.mask = maskLayer;
    self.myImageView.layer.masksToBounds = YES;
    //    设置半径
    self.myImageView.layer.cornerRadius = 3;
    
    
    
    _textLabel = [UILabel new];
    // _textLabel.backgroundColor = [UIColor colorWithRed:1.000 green:0.249 blue:0.417 alpha:1.000];
    [_backView addSubview:_textLabel];
    [_textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.myImageView.mas_bottom).offset(5);
        make.right.mas_equalTo(self).offset(-7);
        make.left.mas_equalTo(self).offset(8);
        make.height.mas_equalTo(40);
    }];
    _textLabel.font = [UIFont fontWithName:@"Gill Sans" size:14];
    _textLabel.textColor = [UIColor colorWithWhite:0.416 alpha:1.000];
    _textLabel.numberOfLines = 0;
    //文子
    //_textLabel.backgroundColor = [UIColor redColor];
    
    _userImageView = [UIImageView new];
    _userImageView.backgroundColor = [UIColor clearColor];
    [_backView addSubview:_userImageView];
    [_userImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(10);
        make.top.mas_equalTo(_textLabel.mas_bottom).offset(6);
        make.width.mas_equalTo(24);
        make.height.mas_equalTo(24);
        
    }];
    _userImageView.layer.masksToBounds = YES;
    //    设置半径
    _userImageView.layer.cornerRadius = 12;
    
    
    
    
    _nameLabel = [UILabel new];
    //_nameLabel.backgroundColor = [UIColor colorWithRed:0.980 green:0.792 blue:0.800 alpha:1.000];
    [_backView addSubview:_nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_userImageView.mas_right).offset(5);
        make.top.mas_equalTo(_userImageView);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(30);
        
    }];
    
    _nameLabel.font = [UIFont fontWithName:@"Gill Sans" size:11];
    _nameLabel.textColor = [UIColor colorWithWhite:0.416 alpha:1.000];
    
    
    

}

- (void)setMyModel:(WJQEverydayModel *)myModel{
    _textLabel.text = myModel.index_title;
    [_myImageView sd_setImageWithURL:[NSURL URLWithString:myModel.index_cover] placeholderImage:PICHOLDEER];
    [_userImageView sd_setImageWithURL:[NSURL URLWithString:myModel.avatar_m] placeholderImage:PICHOLDEER];
    _nameLabel.text  = myModel.name;
}
@end
